/*
	This file is part of Sandbox.

	Copyright (C) 2008  Marleine Daoud <marleine@gmail.com>

	Sandbox is free software: you can redistribute it and/or modify
	it under the terms of the GNU General Public License as published by
	the Free Software Foundation, either version 3 of the License, or
	(at your option) any later version.

	Sandbox is distributed in the hope that it will be useful,
	but WITHOUT ANY WARRANTY; without even the implied warranty of
	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
	GNU General Public License for more details.

	You should have received a copy of the GNU General Public License 
	along with Sandbox.  If not, see <http://www.gnu.org/licenses/>.
*/

#import <node-properties.h>
#import <list.h>
#import <gtk.h>
#import <node.h>
#import <search-by-type.h>
#import <search-by-borderstyle.h>
#import <search-by-fillcolor.h>
#import <search-by-linecolor.h>
#import <search-by-note.h>
#import <string.h>
#import <stdlib.h>

/** 
* Enum for Predicate Type.
* Enum for the Predicate Type as an "and", "or" or "criteria".
*
* @author Marleine Daoud
*/

typedef enum _PredicateType {
	ANDP = 0, /**< enum value "and". */ 
	ORP, /**< enum value "or". */ 
	CRITERIA /**< enum value "criteria". */ 
} PredicateType;

/**
* An interface for the Predicate class. An interface for the Predicate class, it
* inherites from class Object.
*
* @author Marleine Daoud
*/

@interface Predicate : Object {
@public 
	Predicate *p1; /**< instance value p1 of type Predicate pointer. */ 
	Predicate *p2; /**< instance value p2 of type Predicate pointer. */ 
	PredicateType ptype; /**< instance value ptype of type PredicateType. */ 
}

/**
* A method to create the predicates. A method to create the predicates, it takes 
* a GList pointer of predicates as argument including the search criteria and 
* returns a pointer to the created predicate out of the searching criteria. 
* @param predicates a GList pointer to the search criteria.
* @return Predicate pointer to the created predicate.
*/

+ (Predicate *) createPredicates: (GList *) predicates;

/**
* A method to evaluate a predicate. A method to evaluate a predicate, it takes a 
* Node pointer as argument and returns a boolean value set to True if this node 
* satisfies the predicate and as False if it doesn't.
* @param node a Node pointer to a node in the canvas that needs to be evaluated.
* @return Boolean value stating if the node satisfies the predicate or not. 
*/

- (gboolean) evaluate: (Node *) node;

@end

/**
* An interface for the SearchAlgo class. An interface for the SearchAlgorithm 
* (SearchAlgo) class.
*
* @author Marleine Daoud
*/

@interface SearchAlgo {
@protected //these lists can be removed
	List *searchlist; /**< instance value searchlist of type List pointer.*/ 
	List *searchhistorylist; /**< instance value searchhistory of type List 
					 * pointer.*/
}

/**
* A method to initialize a SearchAlgo instance. A method to initialize the 
* SearchAlgo by allocating and initializing the searchlist and the searchhistorylist. 
*/

- init;

/**
* A method to free a SearchAlgo instance. A method to free the SearchAlgo by 
* freeing the searchlist and the searchhistorylist. 
*/

- free;

/**
* A method to convert an integer to string. A method to convert an integer to 
* string needed in the search history.
*
* @author Andrew M. B. Boktor
*/

char* intToString(int val);

/**
* A method to accomplish a simple search. A method to accomplish a simple search 
* on a list of nodes. It takes a List of nodes pointer as argument as well as 
* all the node's properties inserted in the search criteria. It "and"s all the 
* properties together and then selects the nodes fulfilling the condition.
* @param nodeList a List of nodes pointer to all the nodes in the canvas.
* @param type an integer representing the type requested.
* @param style an integer representing the style requested.
* @param linecolorR a float representing the red component of the line color 
* requested.
* @param linecolorG a float representing the green component of the line color 
* requested.
* @param linecolorB a float representing the blue component of the line color 
* requested.
* @param linecolorA a float representing the alpha component of the line color 
* requested.
* @param fillcolorR a float representing the red component of the fill color 
* requested.
* @param fillcolorG a float representing the green component of the fill color 
* requested.
* @param fillcolorB a float representing the blue component of the fill color 
* requested.
* @param fillcolorA a float representing the alpha component of the fill color 
* requested.
* @param note a character array representing the comment requested.
*/

+ search: (List *) nodeList: (int) type: (int) style: (float) linecolorR: 
	(float) linecolorG: (float) linecolorB: (float) linecolorA: 
	(float) fillcolorR: (float) fillcolorG: (float) fillcolorB: 
	(float) fillcolorA: (char *) note;

/**
* A method to create the search history label of each search criteria. A method 
* to create the search history label of each search criteria, it takes a GList
* pointer of the historyList as argument and returns a constante character array 
* which value is set to represent a resume of the search criteria. 
* @param historyList a GList pointer to the historyList including the search 
* criteria.
* @return Constante character array which value is set to represent a resume of 
* the search criteria.  
*/

+ (const char *) createHistoryUI: (GList *) historyList;

@end

/** 
* Enum for Search Type.
* Enum for the Search Type as a "shapetype", "boderstyle", "linecolor", 
* "fillcolor" or "comment".
*
* @author Marleine Daoud
*/

typedef enum _SearchType {
	SHAPETYPE = 0, /**< enum value "shapetype". */
	BORDERSTYLE, /**< enum value "borderstyle". */
	LINECOLOR, /**< enum value "linecolor". */
	FILLCOLOR, /**< enum value "fillcolor". */
	COMMENT /**< enum value "comment". */
} SearchType;

/** 
* Enum for And, Or or Null.
* Enum for the And, Or or Null as an "And", "Or" or "Nul".
*
* @author Marleine Daoud
*/

typedef enum _AndOrNull {
	AND = 0, /**< enum value "and". */
	OR, /**< enum value "or". */
	NUL /**< enum value "null". */
} AndOrNull;

/**
* An interface for the SearchItem class. An interface for the SearchItem class, 
* it inherites from the Predicate class.
*
* @author Marleine Daoud
*/

@interface SearchItem : Predicate {
@public 
	SearchType searchtype; /**< instance value searchtype of type SearchType.*/ 
	AndOrNull andOrNull; /**< instance value andOrNull of type AndOrNull.*/ 
}

@end

/**
* An interface for the SearchByTypeData class. An interface for the SearchByTypeData 
* class, it inherites from the SearchItem class.
*
* @author Marleine Daoud
*/

@interface SearchByTypeData : SearchItem {
@public
	NodeType shapetype; /**< instance value shapetype of type NodeType.*/
	SearchByTypeUI *searchbytypeui; /**< instance value searchbytypeui of 
				* type SearchByTypeUI.*/ 
}

@end

/**
* An interface for the SearchByBorderStyleData class. An interface for the SearchByBorderStyleData 
* class, it inherites from the SearchItem class.
*
* @author Marleine Daoud
*/

@interface SearchByBorderStyleData : SearchItem {
@public
	BorderStyle borderstyle; /**< instance value bordertype of type BorderStyle.*/
	SearchByBorderStyleUI *searchbyborderstyleui; /**< instance value searchbyborderstyleui of 
				* type SearchByBorderStyleUI.*/ 
}

@end

/**
* An interface for the SearchByLineColorData class. An interface for the SearchByLineColorData 
* class, it inherites from the SearchItem class.
*
* @author Marleine Daoud
*/

@interface SearchByLineColorData : SearchItem {
@public
	ColorRGBA linecolor; /**< instance value linecolor of type ColorRGBA.*/
	SearchByLineColorUI *searchbylinecolorui; /**< instance value searchbylinecolorui of 
				* type SearchByLineColorUI.*/ 
}

@end

/**
* An interface for the SearchByFillColorData class. An interface for the SearchByFillColorData 
* class, it inherites from the SearchItem class.
*
* @author Marleine Daoud
*/

@interface SearchByFillColorData : SearchItem {
@public
	ColorRGBA fillcolor; /**< instance value fillcolor of type ColorRGBA.*/
	SearchByFillColorUI *searchbyfillcolorui; /**< instance value searchbyfillcolorui of 
				* type SearchByFillColorUI.*/ 
}

@end

/**
* An interface for the SearchByNoteData class. An interface for the SearchByNoteData 
* class, it inherites from the SearchItem class.
*
* @author Marleine Daoud
*/

@interface SearchByNoteData : SearchItem {
@public
	char *comment; /**< instance value comment of type character array.*/
	SearchByNoteUI *searchbynoteui; /**< instance value searchbynoteui of 
				* type SearchByNoteUI.*/ 
}

@end

